﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

public partial class Admin_Default : System.Web.UI.Page
{
    protected LocalFunctions FUNC;

    protected void Page_Load(object sender, EventArgs e)
    {
        FUNC = ((Admin_AdminMasterPage)Master).FUNC;

        if (!IsPostBack)
        {
            //swfObject.InnerHtml+="<object width=\"580\" height=\"100\">"+
            //    "<param name=\"movie\" value=\"HPBanner.swf\">"+
            //"<embed src=\"../gallery/banners/HPBanner.swf\" width=\"580\" height=\"100\"></embed></object>";

            DataTable DTFooter = Dal.ExecuteDBsp("Admin_GetFooter");
            if (DTFooter != null)
            {
                if (DTFooter.Rows.Count > 0)
                {
                    fckFooterRus.Value = DTFooter.Rows[0]["TextData"].ToString();
                    fckFooterHeb.Value = DTFooter.Rows[1]["TextData"].ToString();
                }
            }
        }
        this.Page.ClientScript.RegisterOnSubmitStatement(
          this.GetType(),
          "AjaxHack",
          "for ( var i = 0; i < parent.frames.length; ++i ) if ( parent.frames[i].FCK ) parent.frames[i].FCK.UpdateLinkedField();"
          );
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        Dal.arParams.Clear();
        Dal.arParams.Add(fckFooterRus.Value);
        Dal.arParams.Add(fckFooterHeb.Value);
        Dal.ExecuteDBsp("Admin_UpdateFooter",Dal.arParams,true);
    }

    protected void uplBanner_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
    {
        string script = string.Empty;
        string sFileName = "HPBanner.swf";
        string sPath = Server.MapPath("~/Gallery/Banners/") + sFileName;
        uplBanner.SaveAs(sPath);

        Response.Redirect(Request.Url.ToString());
    }
}
